﻿<UserControl x:Class="AppToolkit.WPF.Controls.RichTextEditor" x:Name="uxRichTextEditor"    
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:asis="clr-namespace:AppToolkit.WPF.Controls.Utils">
	<UserControl.Resources>
		<!--<asis:NullConverter x:Key="converter" />-->
	</UserControl.Resources>
	<Grid>

		<!-- Set the styles for the tool bar. -->
		<Grid.Resources>
			<Style TargetType="{x:Type Button}" x:Key="formatTextStyle">
				<Setter Property="FontFamily" Value="Palatino Linotype"></Setter>
				<Setter Property="Width" Value="30"></Setter>
				<Setter Property="FontSize" Value ="14"></Setter>
				<Setter Property="CommandTarget" Value="{Binding ElementName=_RTB}"></Setter>
			</Style>

			<Style TargetType="{x:Type Button}" x:Key="formatImageStyle">
				<Setter Property="Width" Value="30"></Setter>
				<Setter Property="CommandTarget" Value="{Binding ElementName=_RTB}"></Setter>
			</Style>
		</Grid.Resources>

		<DockPanel Name="mainPanel" LastChildFill="True">

			<!-- This tool bar contains all the editing buttons. -->
			<ToolBar Height="30" DockPanel.Dock="Top" ToolBarTray.IsLocked="True" >
				<Button Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Cut" ToolTip="Cut">
					<Image Source="Images\editcut.png"></Image>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Copy" ToolTip="Copy">
					<Image Source="Images\EditCopy.png"></Image>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Paste" ToolTip="Paste">
					<Image Source="Images\EditPaste.png"></Image>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Undo" ToolTip="Undo">
					<Image Source="Images\EditUndo.png"></Image>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Redo" ToolTip="Redo">
					<Image Source="Images\EditRedo.png"></Image>
				</Button>

				<Button Style="{StaticResource formatTextStyle}" Command="EditingCommands.ToggleBold" ToolTip="Bold">
					<TextBlock FontWeight="Bold">B</TextBlock>
				</Button>
				<Button Style="{StaticResource formatTextStyle}" Command="EditingCommands.ToggleItalic" ToolTip="Italic">
					<TextBlock FontStyle="Italic" FontWeight="Bold">I</TextBlock>
				</Button>
				<Button Style="{StaticResource formatTextStyle}" Command="EditingCommands.ToggleUnderline" ToolTip="Underline">
					<TextBlock TextDecorations="Underline" FontWeight="Bold">U</TextBlock>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="EditingCommands.IncreaseFontSize" ToolTip="Grow Font">
					<Image Source="Images\CharacterGrowFont.png"></Image>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="EditingCommands.DecreaseFontSize" ToolTip="Shrink Font">
					<Image Source="Images\CharacterShrinkFont.png"></Image>
				</Button>

				<Button Style="{StaticResource formatImageStyle}" Command="EditingCommands.ToggleBullets" ToolTip="Bullets">
					<Image Source="Images\ListBullets.png"></Image>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="EditingCommands.ToggleNumbering" ToolTip="Numbering">
					<Image Source="Images/ListNumbering.png"></Image>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="EditingCommands.AlignLeft" ToolTip="Align Left">
					<Image Source="Images\ParagraphLeftJustify.png"></Image>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="EditingCommands.AlignCenter" ToolTip="Align Center">
					<Image Source="Images\ParagraphCenterJustify.png"></Image>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="EditingCommands.AlignRight" ToolTip="Align Right">
					<Image Source="Images\ParagraphRightJustify.png"></Image>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="EditingCommands.AlignJustify" ToolTip="Align Justify">
					<Image Source="Images\ParagraphFullJustify.png"></Image>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="EditingCommands.IncreaseIndentation" ToolTip="Increase Indent">
					<Image Source="Images\ParagraphIncreaseIndentation.png"></Image>
				</Button>
				<Button Style="{StaticResource formatImageStyle}" Command="EditingCommands.DecreaseIndentation" ToolTip="Decrease Indent">
					<Image Source="Images\ParagraphDecreaseIndentation.png"></Image>
				</Button>
			</ToolBar>

			<RichTextBox Name="_RTB" AcceptsTab="True" LostFocus="OnRTBLostFocus"
												VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
			<!--<TextBox Text="{Binding Path=Text, ElementName=uxRichTextEditor}" Height="25" />-->

		</DockPanel>
	</Grid>
</UserControl>
